package com.bookcloud.java21.chapter13.UI标准对话框135;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/** 标准对话框 */
public class DialogDemo {
  public static void main(String[] args) {
    SwingUtilities.invokeLater(
        () -> {
          JFrame frame = new JFrame("标准对话框");
          frame.setSize(300, 200);
          frame.setVisible(true);
          // 增加按钮
          JButton btn = new JButton("点击我");
          frame.add(btn);
          // 增加事件处理
          btn.addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                  // 显示对话框
                  JOptionPane.showMessageDialog(frame, "你好，世界！");
                }
              });
        });
  }
}
